package com.campus.secondhand.controller;

import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.campus.secondhand.common.Result;
import com.campus.secondhand.model.dto.VerificationCodeDTO;
import com.campus.secondhand.service.VerificationCodeService;

import lombok.RequiredArgsConstructor;

/**
 * 验证码控制器
 */
@RestController
@RequestMapping("/verification")
@RequiredArgsConstructor
public class VerificationCodeController {

    private final VerificationCodeService verificationCodeService;

    /**
     * 发送手机验证码
     * 
     * @param verificationCodeDTO 验证码请求
     * @return 处理结果
     */
    @PostMapping("/code/send")
    public Result<Void> sendVerificationCode(@Validated @RequestBody VerificationCodeDTO verificationCodeDTO) {
        return verificationCodeService.generateAndSendCode(verificationCodeDTO.getPhone());
    }
}